package com.ruoyi.web.controller.fantasy;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.huanzhidadi.fantasy.bean.domain.FantasyNpcPosition;
import com.ruoyi.fantasy.service.INpcpositionsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * fantasynpc位置 信息操作处理
 * 
 * @author wanghui
 * @date 2019-07-05
 */
@Controller
@RequestMapping("/fantasy/npcpositions")
public class NpcpositionsController extends BaseController
{
    private String prefix = "fantasy/npcpositions";
	
	@Autowired
	private INpcpositionsService npcpositionsService;
	
	@RequiresPermissions("fantasy:npcpositions:view")
	@GetMapping()
	public String npcpositions()
	{
	    return prefix + "/npcpositions";
	}
	
	/**
	 * 查询fantasynpc位置列表
	 */
	@RequiresPermissions("fantasy:npcpositions:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(FantasyNpcPosition npcpositions)
	{
		startPage();
        List<FantasyNpcPosition> list = npcpositionsService.selectNpcpositionsList(npcpositions);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出fantasynpc位置列表
	 */
	@RequiresPermissions("fantasy:npcpositions:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FantasyNpcPosition npcpositions)
    {
    	List<FantasyNpcPosition> list = npcpositionsService.selectNpcpositionsList(npcpositions);
        ExcelUtil<FantasyNpcPosition> util = new ExcelUtil<FantasyNpcPosition>(FantasyNpcPosition.class);
        return util.exportExcel(list, "npcpositions");
    }
	
	/**
	 * 新增fantasynpc位置
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存fantasynpc位置
	 */
	@RequiresPermissions("fantasy:npcpositions:add")
	@Log(title = "fantasynpc位置", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(FantasyNpcPosition npcpositions)
	{		
		return toAjax(npcpositionsService.insertNpcpositions(npcpositions));
	}

	/**
	 * 修改fantasynpc位置
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		FantasyNpcPosition npcpositions = npcpositionsService.selectNpcpositionsById(id);
		mmap.put("npcpositions", npcpositions);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存fantasynpc位置
	 */
	@RequiresPermissions("fantasy:npcpositions:edit")
	@Log(title = "fantasynpc位置", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(FantasyNpcPosition npcpositions)
	{		
		return toAjax(npcpositionsService.updateNpcpositions(npcpositions));
	}
	
	/**
	 * 删除fantasynpc位置
	 */
	@RequiresPermissions("fantasy:npcpositions:remove")
	@Log(title = "fantasynpc位置", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(npcpositionsService.deleteNpcpositionsByIds(ids));
	}
	
}
